package com.uzai.console.web.tb.tbexclusivegoods;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.pyqmaterial.TurnlinkDto;
import com.uzai.console.dto.tb.tbexclusivegoods.*;
import com.uzai.console.dto.turnlink.TurnLinkGoodsAnalyzeDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.tb.tbexclusivegoods.TbExclusiveGoodsService;
import com.uzai.console.vo.feign.turnlink.SimpleTurnlinkVo;
import com.uzai.console.vo.tb.tbexclusivegoods.TbExclusiveGoodsVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 淘宝定向商品管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "定向商品",tags = "淘宝|定向商品")
@ApiSort(7)
@RestController
public class TbExclusiveGoodsController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(TbExclusiveGoodsController.class);

    @Autowired
    private TbExclusiveGoodsService tbExclusiveGoodsService;

    @ApiOperation(value = "分页查询淘宝定向商品列表", notes = "分页查询淘宝定向商品列表", response = TbExclusiveGoodsVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/tbExclusiveGoods/findByPage")
    public Object findByPage(@RequestBody TbExclusiveGoodsQuery tbExclusiveGoodsQuery){
        return tbExclusiveGoodsService.findTbExclusiveGoodsList(tbExclusiveGoodsQuery);
    }

    @ApiOperation(value = "查询淘宝定向商品信息", notes = "查询淘宝定向商品信息", response = TbExclusiveGoodsVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/tbExclusiveGoods/findById")
    public Object findById(@RequestBody TbExclusiveGoodsIdDto tbExclusiveGoodsIdDto){
        return tbExclusiveGoodsService.findTbExclusiveGoods(tbExclusiveGoodsIdDto);
    }

    @SystemLogType(model = SystemModelEnum.TbExclusiveGoods, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加淘宝定向商品信息", notes = "添加淘宝定向商品信息")
    @ApiOperationSupport(order = 3)
    @PostMapping("/tbExclusiveGoods/add")
    public Object add(@RequestBody TbExclusiveGoodsDto tbExclusiveGoodsInfoDto){
        tbExclusiveGoodsService.addTbExclusiveGoods(tbExclusiveGoodsInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TbExclusiveGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑淘宝定向商品信息", notes = "编辑淘宝定向商品信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/tbExclusiveGoods/update")
    public Object update(@RequestBody TbExclusiveGoodsDto tbExclusiveGoodsInfoDto){
        tbExclusiveGoodsService.updateTbExclusiveGoods(tbExclusiveGoodsInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.TbExclusiveGoods, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除淘宝定向商品信息", notes = "删除淘宝定向商品信息")
    @ApiOperationSupport(order = 5)
    @PostMapping("/tbExclusiveGoods/delete")
    public Object delete(@RequestBody TbExclusiveGoodsIdListDto cikuKeywordsReplyIdListDto){
        tbExclusiveGoodsService.deleteTbExclusiveGoods(cikuKeywordsReplyIdListDto);
        return true;
    }

    @ApiOperation(value = "获取淘宝定向商品信息", notes = "获取淘宝定向商品信息", response = SimpleTurnlinkVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/tbExclusiveGoods/getGoodInfo")
    public Object getGoodInfo(@RequestBody TbExclusiveGoodsTurnLinkDto tbExclusiveGoodsTurnLinkDto){
        return tbExclusiveGoodsService.getGoodInfo(tbExclusiveGoodsTurnLinkDto);
    }

}
